﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class WinPopupControl : MonoBehaviour
{
	public List<Image> listStars;
	public void Start()
	{
		//AdsControl.Instance.showAds ();
	}

	void OnEnable ()
	{
		
		Time.timeScale = 0;
		AudioManager.instance.PlaySound (AudioClipType.level_win);
		if (GameManager.currentLevel == GameManager.dataSave.levelMax) {
			if (GameManager.dataSave.levelMax < 15) {
				GameManager.dataSave.levelMax++;
				GameManager.dataSave.coin++;
				GameManager.SaveData ();
			}
		}
	}

	void InitStar ()
	{
		for (int i = 0; i < listStars.Count; i++) {			
			listStars [i].gameObject.SetActive (false);
		}
		int star = 0;
		int hpMax = 20 + GameManager.dataSave.hpAdd;
		if (GameplayControl.instance.hp >= 2 * hpMax / 3) {
			star = 3;
		} else if (GameplayControl.instance.hp >= 1 * hpMax / 3 && GameplayControl.instance.hp < 2 * hpMax / 3) {
			star = 2;
		} else if (GameplayControl.instance.hp > 0 && GameplayControl.instance.hp < 2 * hpMax / 3) {
			star = 1;
		}
		for (int i = 0; i < listStars.Count; i++) {
			if (i < star) {
				listStars [i].gameObject.SetActive (true);
			}
		}
	}
}
